package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Mapper
public interface SetmealMapper {
    @Select("select count(*) from setmeal where category_id = #{id} and status = 1")
    Integer findById(Integer id);

    /**
     * 分页查询
     * @param setmeal
     * @return
     */
    Page<SetmealVO> page(SetmealVO setmealVO);

    @AutoFill(OperationType.INSERT)
    void save(Setmeal setmeal);

    @Select("select * from setmeal where id = #{id}")
    Setmeal seleteById(Long id);

    /**
     * 更新套餐
     * @param setmeal
     */
    void update(Setmeal setmeal);


    Integer findBySetmealId(List<Long> ids);

    /**
     * 删除
     * @param id
     */
    @Delete("delete from setmeal where id = #{id}")
    void deleteById(Long id);

    /**
     * 根据分类id查询套餐
     * @param categoryId
     * @return
     */
    List<Setmeal> list(Long categoryId);

    /**
     * 查询套餐总览
     * @param enable
     * @return
     */
    @Select("select count(*) from setmeal where status = #{status}")
    Integer findByStatus(Integer status);
}
